<template>
  <div>
    <el-table v-loading="loading" :data="noticeList">
      <el-table-column label="序号" align="center" prop="order" width="50" />
      <el-table-column label="设备编号" align="center" prop="noticeType" min-width="100">
        <template slot-scope="scope">
          <el-link @click="handledetailed(scope.row)" type="primary">{{ scope.row.equipmentNum || '-' }}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="资产编号" align="center" prop="noticeType" min-width="100">
        <template slot-scope="scope">
          <el-link @click="handledetailed(scope.row)" type="primary">{{ scope.row.assetNum || '-' }}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="设备名称" align="center" min-width="150" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.equipmentName || '-' }}
        </template>
      </el-table-column>
      <!-- <el-table-column label="设备状态" align="center" min-width="130">
        <template slot-scope="scope">
          <dict-tag :options="statusDevicedist" :value="scope.row.status" />
        </template>
      </el-table-column>
      <el-table-column label="使用状态" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.userStatusName || '-' }}
        </template>
      </el-table-column> -->
      <el-table-column label="负责人" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.headName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="品牌" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.brand || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="规格型号" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.model || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="所属部门" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.deptName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="位置" align="center" min-width="120">
        <template slot-scope="scope">
          {{ scope.row.placeName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="单位" align="center" min-width="60">
        <template slot-scope="scope">
          {{ scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.unitName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="供应商" align="center" min-width="120" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.supplierName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="采购日期" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.purchaseTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="采购金额（元）" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.purchasePrice === null ? '****' : scope.row.purchasePrice }}
        </template>
      </el-table-column>
      <el-table-column label="验收日期" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.acceptanceTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="保质期至" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.shelfLife || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="启用日期" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.enableTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="预计报废日期" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.estimatedScrapTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="净值（元）" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.netWorth === null ? '****' : scope.row.netWorth }}
        </template>
      </el-table-column>
      <el-table-column label="计量设备" align="center" min-width="130">
        <template slot-scope="scope">
          {{ meterageFlag[scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.meterageFlag] || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="计量编号" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.meterageNum || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="类别" align="center" min-width="120">
        <template slot-scope="scope">
          {{ scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.typeName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" min-width="150" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.remark || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="附件" align="center" min-width="120">
        <template slot-scope="scope">
          <el-link :disabled="!(scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.file)" icon="el-icon-document"
            type="primary" :href="scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.file" target="_blank">
            附件资料</el-link>
        </template>
      </el-table-column>
      <el-table-column label="盘亏时间" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.checkTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="创建部门" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.deptName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="创建人" align="center" min-width="120" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.createBy || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="180" fixed="right" align="center">
        <template slot-scope="scope">
          <el-button v-hasPermi="['ledger_reuse_img']" size="small" type="primary" icon="el-icon-view"
            @click="handleSelectImage(scope.row.equipmentBaseVo && scope.row.equipmentBaseVo.image)">图片
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="card-div">
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
    <template v-if="ImageOpen">
      <DialogImage :src="ImageSrc"></DialogImage>
    </template>
  </div>
</template>

<script>
import { getequipmentlist } from "@/api/equipment/equipment.js";

export default {
  name: "loss",
  // dicts: ['sys_notice_status', 'sys_notice_type'],
  components: {
  },
  data () {
    return {
      // 遮罩层
      ImageOpen: false,
      ImageSrc: '',
      loading: true,
      opendetailed: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      dictdatalist: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层表格数据
      noticeList: [],
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        'params[userStatuses]': '5',//已报废
        orderByColumn: 'equipmentAccountId',
        isAsc: 'desc'//倒叙
      },
    };
  },
  computed: {
    purchasePriceDisplayFlag () {//默认不展示采购金额
      return this.$store.state.reuseVariable.PriceDisplay
    }
  },
  created () {
    this.getList();
  },
  mounted () {
    // console.log(this.dict.type.sys_notice_status);
  },
  methods: {
    handleSelectImage (src) {
      this.ImageOpen = true
      this.ImageSrc = src
    },
    /** 查询列表 */
    async getList (value) {
      this.loading = true;
      let objects = value || {}
      let params = {
        ...this.queryParams,
        ...objects,
        'equipmentBaseVo.equipmentName': objects.equipmentName || '',//设备名称
        'equipmentBaseVo.typeName': objects.typeName || '',//设备类别
        purchasePriceDisplayFlag: this.purchasePriceDisplayFlag

      }
      //  let data = await getdatalist({ dictType: 'base_unit' })
      //  this.dictdatalist=data.data
      getequipmentlist(params).then(response => {
        this.noticeList = response.data && response.data.map((item, index) => {
          return {
            ...item,
            order: index + 1
          }
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel () {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset () {
      this.form = {
        noticeId: undefined,
        noticeTitle: undefined,
        noticeType: undefined,
        noticeContent: undefined,
        status: "0"
      };
      this.resetForm("form");
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 打开详细弹窗
    handledetailed (row) {

      this.$parent.$parent.$parent.$parent.tabIndex = true
      this.$parent.$parent.$parent.$parent.activeName = '6'
      this.$parent.$parent.$parent.$parent.rowObj = row
    },
    /** 修改按钮操作 */
    handleUpdate (row) {
      this.rowObj = row
      this.open = true
    },
    // 多选框选中数据
    handleSelectionChange (selection) {
      this.ids = selection.map(item => item.noticeId)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },

  },
  filters: {
  }
};
</script>
<style lang="scss" scoped>
.red {
  color: red;
}
</style>